package com.eqdd.yiqidian.ui.mine;

import android.content.Intent;
import android.databinding.DataBindingUtil;

import com.eqdd.yiqidian.R;
import com.eqdd.yiqidian.adapter.recycleadapter.BaseQuickAdapter;
import com.eqdd.yiqidian.adapter.recycleadapter.BaseViewHolder;
import com.eqdd.yiqidian.adapter.recycleadapter.ItemClickSupport;
import com.eqdd.yiqidian.base.BaseActivity;
import com.eqdd.yiqidian.ForeignActivityCustom;
import com.eqdd.yiqidian.base.Config;
import com.eqdd.yiqidian.widget.ChooseAlertView;
import com.eqdd.yiqidian.widget.EditDialogFragment;

import android.support.v7.widget.LinearLayoutManager;
import android.view.View;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class ForeignActivity extends BaseActivity {
    private ForeignActivityCustom dataBinding;
    private BaseQuickAdapter<String, BaseViewHolder> quickAdapter;
    private List<String> items = new ArrayList<>();
    private String[] itemContents;
    private int clicked;
    private EditDialogFragment editDiglog;

    @Override
    public void initBinding() {
        dataBinding = DataBindingUtil.setContentView(this, R.layout.activity_foreign);
        initTopTitleBar(View.VISIBLE, "选择");
    }

    @Override
    public void initData() {
        itemContents = getResources().getStringArray(R.array.english);
        for (String itemContent : itemContents) {
            items.add(itemContent);
        }
    }

    @Override
    public void setView() {

        if (quickAdapter == null) {
            dataBinding.recyclerView.setLayoutManager(new LinearLayoutManager(this));
            quickAdapter = new BaseQuickAdapter<String, BaseViewHolder>(R.layout.list_item_14, items) {

                @Override
                protected void convert(BaseViewHolder helper, String item) {
                    helper.setText(R.id.tv_content, item);
                }
            };
            dataBinding.recyclerView.setAdapter(quickAdapter);
            if (items != null) {
                ArrayList<String> temp = new ArrayList<>();
                temp.addAll(items);
                quickAdapter.notifyDataChanged(temp, true);
                ItemClickSupport.addTo(dataBinding.recyclerView)
                        .setOnItemClickListener((rv, position, v) -> {
                            Intent intent = new Intent();
                            intent.putExtra("content", quickAdapter.getItem(position));
                            setResult(Config.INTENT_CONTENT, intent);
                            finish();
                        });
            }
        }
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {

        }
    }


}
